<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>写笔记</title>
</head>
<body>

<div class="main">

    <div class="edit-box">

        <div id="toolBar" class="tool-bar">
            <span class="bar">
                    <a class="undo disabled" href="javascript:void(0)" type="undo"></a>
                    <a class="redo disabled" href="javascript:void(0)" type="redo"></a>
            </span>
            <span class="bar">
                <a class="hx" type="hx" href="javascript:void(0)">Hx</a>
                <a class="hx-child" type="hx-child" href="javascript:void(0)">HxChild</a>
                <a class="hx-parent" type="hx-parent" href="javascript:void(0)">HxParent</a>
                <a href="javascript:void(0)" type="h2">H2</a>
                <a href="javascript:void(0)" type="h3">H3</a>
                <a href="javascript:void(0)" type="h4">H4</a>
                <a href="javascript:void(0)" type="h5">H5</a>
            </span>
            <span class="bar cf">
                  <a class="em-red" type="em-red" href="javascript:void(0)">EM</a>
                <a class="t1" type="t1" href="javascript:void(0)">T1</a>
                <a class="removeformat" type="removeformat" href="javascript:void(0)"></a>
                <a class="hyperlink" type="hyperlink" href="javascript:void(0)"></a>

                <a class="del-elem" type="del-elem" href="javascript:void(0)">DelElem</a>
                <a id="save" class="save" type="save" href="javascript:void(0)">SAVE</a>
            </span>
            <span class="bar cf">
                <a class="code-line" href="javascript:void(0)">codeLine</a>
                <a class="code-js" href="javascript:void(0)">js</a>
                <a class="code-css" href="javascript:void(0)">css</a>
                <a class="code-html" href="javascript:void(0)">html</a>
                <a class="code-scss" href="javascript:void(0)">scss</a>
                <a class="code-powershell" href="javascript:void(0)">PowerShell</a>
            </span>
            <span class="bar">
            <a class="copy" href="javascript:void(0)">copyAll</a>

            <a href="javascript:void(0)" type="test">test</a>
            </span>
        </div>
        <div class="edit-cont note" contenteditable="true">
            <div class="content">
                <div class="h2-main">
                    <h2>表达式创建</h2>
                    <div class="content"><p><br></p>
                        <p class="t1">字面量创建</p>
                        <div class="code-box code-js">
                            <pre><span class="token keyword">var</span> reg<span class="token operator">=</span><span
                                    class="token regex">/,{2,}/</span><span class="token punctuation">;</span></pre>
                        </div>
                        <p>修饰符</p>
                        <p>/pattern/g：</p>
                        <p>/pattern/i：不区分大小写(默认是区分的)</p>
                        <p>/pattern/m：更改^和$作用，变成每行头尾(默认只表示字符串的开头和结尾)。如/^b/m将匹配到'test\nbbs'</p>
                        <p><br></p>
                        <p><br></p>
                        <p class="t1">构造函数创建</p>
                        <p>好处是可以根据<span class="em-red">字符串创建</span>，以在运行时动态创建想要的正则表达式</p>
                        <div class="code-box code-js">
                            <pre><span class="token keyword">var</span> reg <span class="token operator">=</span> <span
                                    class="token keyword">new</span>  <span class="token class-name">RegExp</span><span
                                    class="token punctuation">(</span><span class="token string">'[\\d]{2,}'</span><span
                                    class="token punctuation">,</span><span class="token string">'gi'</span><span
                                    class="token punctuation">)</span><span class="token punctuation">;</span></pre>
                        </div>
                        <p>•g （全文查找）&nbsp;</p>
                        <p>•i （忽略大小写）&nbsp;</p>
                        <p>•m （多行查找）</p>
                        <p>根据字符串 创建方式，需保证 最后输出字符串与 / / （斜杠方式）这种方式中的字符需全等（这里弄错了，只要不会有歧义就行）</p>
                        <p><br></p>
                        <p><br></p></div>
                </div>
                <div class="h2-main"><h2>某些错误观点</h2>
                    <div class="content">
                        <div class="h3-main"><h3>创建多个相同的正则表达式，都将引用同一个？</h3>
                            <div class="content"><p>这种特性再es5中有所改变，而且还有可能因浏览器的不同而不同<br></p>
                                <div class="code-box code-js"><pre><span class="token keyword">function</span> <span
                                        class="token function">getRe</span><span class="token punctuation">(</span><span
                                        class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">var</span> re <span class="token operator">=</span> <span
                                            class="token regex">/[a-z]/</span><span class="token punctuation">;</span>
    re<span class="token punctuation">.</span>foo<span class="token operator">=</span><span
                                            class="token string">"bar"</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> re<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">var</span> reg <span class="token operator">=</span> <span
                                            class="token function">getRe</span><span
                                            class="token punctuation">(</span><span
                                            class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> reg2 <span class="token operator">=</span> <span
                                            class="token function">getRe</span><span
                                            class="token punctuation">(</span><span
                                            class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span
                                            class="token punctuation">(</span>reg<span class="token operator">===</span>reg2<span
                                            class="token punctuation">)</span><span
                                            class="token punctuation">;</span><span class="token comment"
                                                                                    spellcheck="true">//true</span>
reg<span class="token punctuation">.</span>foo<span class="token operator">=</span><span
                                            class="token string">"baz"</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span
                                            class="token punctuation">(</span>reg2<span
                                            class="token punctuation">.</span>foo<span
                                            class="token punctuation">)</span><span
                                            class="token punctuation">;</span><span class="token comment"
                                                                                    spellcheck="true">//"baz"</span></pre>
                                </div>
                                <p><br></p>
                                <p class="em-red">这是某书中说的。实测，ie6都不是这样的。。。</p>
                                <div><br></div>
                                <div><br></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>

</div>


</body>
</html>